#!/usr/bin/env python

import MySQLdb

conn = MySQLdb.connect('172.16.1.163', 'gamevil', 'vlwlrpaqlf', 'pz_user')
csr  = conn.cursor()

sql = """
	select seq, user_seq, gold from info_character where user_seq = %s and isDelete=0;
"""

fd = open("character.txt")
for line in fd.xreadlines() :
	user_seq = line.strip();
	csr.execute(sql % user_seq)

	max_gold = 0;
	character_seq = 0;
	for res in csr.fetchall() :
		cseq, useq, gold = res
		if (max_gold < gold) :
			max_gold = gold
			character_seq = cseq

	print "%s,%d,%d" % (user_seq, character_seq, max_gold)

fd.close()

csr.close()
conn.close()
